#ifndef _AS_MOBILE_COMPONENT_H_
#define _AS_MOBILE_COMPONENT_H_

#include "ASEntity.h"
#include "ASComponent.h"
#include "ASWall2D.h"

NS_AS_BEGIN

class ASMobileControler;
class ASMobileComponent:public ASComponent
{
	ASComponentNameDeclare(ASMobileComponent);
public:
	ASMobileComponent();

	virtual ~ASMobileComponent();
	ASMobileControler* getMobileControler(){return _mobileControler;}

	//virtual void update(float dt) override{};
	//virtual void updateBefore() override{};
	//virtual void updateAfter() override{};
	//virtual void onEnter() override{};
	//virtual void onExit() override{};
	

	void setAim(const Vector2D& aim){_vAim = aim;_vAim.Accuracy(AS_VECTOR_ACCURACY);}
	const Vector2D& getAim(){return _vAim;}
	
	
protected:
	//unsigned int _collideRadius;
	friend class ASMobileControler;
	//setMobileControler will be call by ASMobileControler::addMobile
	void setMobileControler(ASMobileControler* controller){_mobileControler = controller;}
	
	ASMobileControler* _mobileControler;
	Vector2D _vAim;
	
};





class ASMobileControler:public sigslot::has_slots<>
{
public:
	ASMobileControler();
	~ASMobileControler();
	void addMobile(ASMobileComponent* pMobile);
	void addMobile(ASEntity* pMobile,ASMobileComponent* pMobileComponent);
	void addObstacle(ASEntity* pObstacle);
	void removeObstacle(ASEntity* pObstacle);
	void removeMobile(ASMobileComponent* pMobile);
	
	void removeByObstacleObj(ASObject* pEntity){removeObstacle((ASEntity*)pEntity);};
	void removeByMobileObj(ASObject* pMobile){removeMobile((ASMobileComponent*)pMobile);};
	void tagMobileWithinViewRange(ASEntity* pEntity,double radius);
	void tagObstacleWithinViewRange(ASEntity* pEntity,double radius);
	
	const std::vector<ASEntity*>& getMobiles(){return _vMobiles;}
	const std::vector<ASEntity*>& getObstacles(){return _vObstacles;}
	const std::vector<ASWall2D>& getWalls(){return _vWalls;}
private:
	std::vector<ASEntity*> _vMobiles;
	std::vector<ASEntity*> _vObstacles;
	std::vector<ASWall2D> _vWalls;
};


NS_AS_END

#endif